import request from '@/utils/request'

// 查询任务发布列表
export function listTask(query) {
  return request({
    url: '/publisher/task/list',
    method: 'get',
    params: query
  })
}

// 查询任务发布详细
export function getTask(id) {
  return request({
    url: '/publisher/task/' + id,
    method: 'get'
  })
}

// 新增任务发布
export function addTask(data, userIds) {
  return request({
    url: `/publisher/task?${userIds.map(value => `userId=${encodeURIComponent(value)}`).join('&')}`,
    method: 'post',
    data: data
  })
}

// 修改任务发布
export function updateTask(data) {
  return request({
    url: '/publisher/task',
    method: 'put',
    data: data
  })
}

// 删除任务发布
export function delTask(id, fileId) {
  return request({
    url: `/publisher/task/${id}/${fileId}`,
    method: 'delete'
  })
}

// 删除在数据库中的数据
export function deleteFile(id) {
  return request({
    url: `/publisher/task/file/${id}`,
    method: 'delete'
  })
}

// 删除远程文件
export function delFileMinio(name) {
  return request({
    url: `/file/delete/${name}`,
    method: 'delete'
  })
}

// 修改文件id为null
export function upadtaFileId(id) {
  return request({
    url: `/publisher/task/${id}`,
    method: 'put',
  })
}
